package cn.tedu.charging.device.controller;

import cn.tedu.charging.common.pojo.GunStatusUpdateParam;
import cn.tedu.charging.common.pojo.JsonResult;
import cn.tedu.charging.common.vo.StationInfoVO;
import cn.tedu.charging.device.service.DeviceService;
import com.alibaba.nacos.shaded.org.checkerframework.checker.units.qual.A;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("device")
@Api(tags = "设备接口")
public class DeviceController {
    @Autowired
    private DeviceService deviceService;
    @ApiOperation("获取场站信息")
    @GetMapping("station/info/{gunId}")
    public JsonResult getStationInfo(@PathVariable("gunId")Integer gunId){
        log.debug("获取场站信息:{}",gunId);
        StationInfoVO stationInfoVO=deviceService.getStationInfo(gunId);
        JsonResult ok =JsonResult.ok(stationInfoVO);
        log.debug("获取场站信息:{},出参:{}",gunId,ok);
        return ok;
    }
    @ApiOperation("更新枪状态")
    @PostMapping("station/gun/status/update")
    public JsonResult updateStatus(@RequestBody GunStatusUpdateParam param){
        log.debug("获取场站信息:{}",param);
        Boolean success=deviceService.updateGunStatus(param);
        JsonResult ok =JsonResult.ok(success);
        log.debug("获取场站信息:{},出参:{}",param,ok);
        return ok;
    }

}
